use warnings;
use Test::More tests => '27';
use Inline C;

is(init(), 0, 'initialize, should return 0');
is(alloc(0), 0, 'alloc memory for 0, should return 0');
is(alloc(1), 1, 'alloc memory for 1, should return 1');
is(alloc(2), 2, 'alloc memory for 2, should return 2');
is(alloc(3), 3, 'alloc memory for 3, should return 3');
is(alloc(4), 4, 'alloc memory for 4, should return 4');
is(alloc(5), 5, 'alloc memory for 5, should return 5');
is(alloc(6), 6, 'alloc memory for 6, should return 6');
is(alloc(7), 7, 'alloc memory for 7, should return 7');
is(alloc(8), 8, 'alloc memory for 8, should return 8');
is(alloc(9), 9, 'alloc memory for 9, should return 9');
is(alloc(10), -1, 'now pool is full, return MEM_ERR(-1)');

is(_free(0), 0, 'free memory for 0, should return 0');
is(_free(1), 0, 'free memory for 1, should return 0');
is(_free(2), 0, 'free memory for 2, should return 0');
is(_free(3), 0, 'free memory for 3, should return 0');
is(_free(4), 0, 'free memory for 4, should return 0');
is(_free(5), 0, 'free memory for 5, should return 0');
is(_free(6), 0, 'free memory for 6, should return 0');
is(_free(7), 0, 'free memory for 7, should return 0');
is(_free(8), 0, 'free memory for 8, should return 0');
is(_free(9), 0, 'free memory for 9, should return 0');
is(_free(0), -2, 'free nonexistence memory 0, should return MEM_NO_ITEM(-2)');
is(alloc(9), 9, 'alloc memory for 9, should return 9');
is(_free(0), -2, 'free nonexistence memory 0, should return MEM_NO_ITEM(-2)');
is(_free(9), 0, 'free memory for 9, should return 0');
is(_free(8), -2, 'free nonexistence memory 8, should return MEM_NO_ITEM(-2)');


__END__
__C__
#include <stdio.h>
#include <stdlib.h>
#include "../../../../mac/list.h"
#include "../../../../mac/list.c"
#include "../../../../mac/mem.h"
#include "../../../../mac/mem.c"
#include "mem_test.c"

int init()
{
    return b_init();
}

int alloc(int id)
{
    return b_alloc(id);
}

int _free(int id)
{
    return b_free(id);
}


